<%--
  Created by IntelliJ IDEA.
  User: 22328
  Date: 2021/2/16
  Time: 13:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>订单编辑</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
</head>

<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form" onsubmit="return false">
            <div class="layui-form-item" style="display: none">
                <label for="id" class="layui-form-label">
                    ID</label>
                <div class="layui-input-inline">
                    <input type="text" id="id" name="id" value="${orders.id}" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="consignee" class="layui-form-label">
                    收货人</label>
                <div class="layui-input-inline">
                    <input type="text" id="consignee" name="consignee" value="${address.consignee}" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="phone" class="layui-form-label">
                    手机</label>
                <div class="layui-input-inline">
                    <input type="text" id="phone" name="phone" value="${address.consigneePhone}" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="shipAddress" class="layui-form-label">
                    <span class="x-red">*</span>收货地址</label>
                <div class="layui-input-inline">
                    <input type="text" id="shipAddress" name="shipAddress" value="${address.shipAddress}" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="logisticsType" class="layui-form-label">
                    <span class="x-red">*</span>配送物流</label>
                <div class="layui-input-inline">
                    <select id="logisticsType" name="logisticsType" class="valid">
                        <c:if test="${orders.logisticsType==0||orders.logisticsType==null}">
                            <option value="0">请选择</option>
                            <option value="1">顺丰速运</option>
                            <option value="2">圆通快递</option>
                            <option value="3">中通快递</option>
                            <option value="4">百事通</option>
                            <option value="5">中国邮政</option>
                            <option value="6">宅急送</option>
                        </c:if>
                        <c:if test="${orders.logisticsType==1}">
                            <option value="1">顺丰速运</option>
                        </c:if>
                        <c:if test="${orders.logisticsType==2}">
                            <option value="2">圆通快递</option>
                        </c:if>
                        <c:if test="${orders.logisticsType==3}">
                            <option value="3">中通快递</option>
                        </c:if>
                        <c:if test="${orders.logisticsType==4}">
                            <option value="4">百事通</option>
                        </c:if>
                        <c:if test="${orders.logisticsType==5}">
                            <option value="5">中国邮政</option>
                        </c:if>
                        <c:if test="${orders.logisticsType==6}">
                            <option value="6">宅急送</option>
                        </c:if>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="payType" class="layui-form-label">
                    支付方式</label>
                <div class="layui-input-inline">
                    <select id="payType" name="payType">
                        <c:if test="${orders.payType==1 || orders.payType==null}">
                            <option value="1">支付宝</option>
                            <option value="2">微信</option>
                            <option value="3">网银</option>
                        </c:if>
                        <c:if test="${orders.payType==2}">
                            <option value="2">微信</option>
                            <option value="1">支付宝</option>
                            <option value="3">网银</option>
                        </c:if>
                        <c:if test="${orders.payType==3}">
                            <option value="3">网银</option>
                            <option value="1">支付宝</option>
                            <option value="2">微信</option>
                        </c:if>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="orderStatus" class="layui-form-label">
                    <span class="x-red">*</span>订单状态</label>
                <div class="layui-input-inline">
                    <select id="orderStatus" name="orderStatus">
                        <c:if test="${orders.orderStatus==0}">
                            <option value="0">待发货</option>
                            <option value="1">已发货</option>
                            <option value="2">待签收</option>
                            <option value="3">已签收</option>
                            <option value="4">待评价</option>
                            <option value="5">已完成</option>
                        </c:if>
                        <c:if test="${orders.orderStatus==1}">
                            <option value="1">已发货</option>
                            <option value="2">待签收</option>
                            <option value="3">已签收</option>
                            <option value="4">待评价</option>
                            <option value="5">已完成</option>
                        </c:if>
                        <c:if test="${orders.orderStatus==2}">
                            <option value="2">待签收</option>
                            <option value="3">已签收</option>
                            <option value="4">待评价</option>
                            <option value="5">已完成</option>
                        </c:if>
                        <c:if test="${orders.orderStatus==3}">
                            <option value="3">已签收</option>
                            <option value="4">待评价</option>
                            <option value="5">已完成</option>
                        </c:if>
                        <c:if test="${orders.orderStatus==4}">
                            <option value="4">待评价</option>
                            <option value="5">已完成</option>
                        </c:if>
                        <c:if test="${orders.orderStatus==5}">
                            <option value="5">已完成</option>
                        </c:if>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_email" class="layui-form-label">
                    <span class="x-red">*</span>发票抬头</label>
                <div class="layui-input-inline">
                    <input type="text" id="L_email" name="email" class="layui-input"></div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span></div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label for="desc" class="layui-form-label">订单包含商品</label>
                <div class="layui-input-block">
                    <table class="layui-table">
                        <tbody style="text-align: center">
                        <tr>
                            <th style="text-align: center">商品名</th>
                            <th style="text-align: center">商品描述</th>
                            <th style="text-align: center">商品单价</th>
                            <th style="text-align: center">图片</th>
                            <th style="text-align: center">操作</th>
                        </tr>
                        <c:forEach items="${goodsList}" var="goods">
                            <tr>
                                <td>${goods.goodsName}</td>
                                <td>${goods.goodsDesc}</td>
                                <td>${goods.goodsPrice}</td>
                                <td><img src="${goods.goodsImg}" style="width: 100px;height: 110px;"></td>
                                <td><a href="./goodsDetail?id=${goods.id}" target="_blank">商品查看</a></td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label for="desc" class="layui-form-label">描述</label>
                    <div class="layui-input-block">
                        <textarea placeholder="请输入内容" id="desc" name="desc" class="layui-textarea"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"></label>
                    <button class="layui-btn" id="add_btn">修改</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript" src="./js/jquery-3.1.0.min.js"></script>
<script>
    layui.use(['form', 'layer'], function () {
        var form = layui.form,
            layer = layui.layer;
    });
    $(function () {
        $("#add_btn").click(function () {
            var id = $("#id").val();
            var shipAddress = $("#shipAddress").val();
            var logisticsType = $("#logisticsType").val();
            var orderStatus = $("#orderStatus").val();
            $.ajax({
                url: "./updateOrders",
                type: "post",
                data: {
                    id:id,
                    shipAddress:shipAddress,
                    logisticsType:logisticsType,
                    orderStatus:orderStatus
                },
                success: function (res) {
                    if (res.data === "修改成功") {
                        layer.alert("修改成功", {
                                icon: 6
                            },
                            function () {
                                //关闭当前frame
                                xadmin.close();
                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            });
                    } else {
                        layer.msg("修改失败");
                    }
                },
                error: function () {
                    alert("404.html页面");
                }
            });
        });
    });
</script>
<script>var _hmt = _hmt || [];
(function () {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();</script>
</body>

</html>
